// 最长上升子序列
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 110;
int n, k;
int dp[N];
int re_dp[N];

int main()
{
    cin >> k;
    while (k --)
    {
        vector<int> vec;
        cin >> n;
        for(int i = 0; i <= n; i ++)
        {
            dp[i] = 1;
            re_dp[i] = 1;
        }
        while (n -- ) 
        {
            int a;
            cin >> a;
            vec.push_back(a);
        }
        n = vec.size();
        int res = 0;
        // 正序
        for (int i = 2; i <= n; i ++ )
        {
            for (int j = 1; j < i; j ++ )
                if (vec[i - 1] > vec[j - 1]) 
                    dp[i] = max(dp[j] + 1, dp[i]);
            res = max(res, dp[i]);
        }

        // 反序        
        reverse(vec.begin(), vec.end());
        re_dp[1] = 1;
        for (int i = 2; i <= n; i ++ )
        {
            for (int j = 1; j < i; j ++ )
                if (vec[i - 1] > vec[j - 1]) 
                    re_dp[i] = max(re_dp[j] + 1, re_dp[i]);
            res = max(res, re_dp[i]);
        }
        cout << res << endl;
    }
    return 0;
}